package cz.myslivec.slovicka.xml.converter;

import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;

import cz.myslivec.slovicka.entity.TestedVocable;
import cz.myslivec.slovicka.util.converter.AConverterBase;
import cz.myslivec.slovicka.xml.model.TestedVocableDTO;

@Name("testedVocableConverter")
@AutoCreate
public class TestedVocableConverter extends AConverterBase<TestedVocable, TestedVocableDTO> {

	public TestedVocableConverter() {
		super();
	}

	@Override
	protected TestedVocableDTO getTo(TestedVocableDTO result, TestedVocable from) {
		result.setId(from.getId());
		result.setSuccessLevel(from.getSuccessLevel());
		result.setTestDate(from.getTestDate());
		result.setVocableId(from.getVocable().getId());
		
		result.seteFactor(from.geteFactor());
		result.setNextTestDate(from.getNextTestDate());
		result.setTestInterval(from.getTestInterval());
		result.setTestCount(from.getTestCount());
		
		return result;
	}

	@Override
	protected TestedVocable getFrom(TestedVocable result, TestedVocableDTO to) {
		result.setId(to.getId());
		result.setSuccessLevel(to.getSuccessLevel());
		result.setTestDate(to.getTestDate());
		result.setVocableId(to.getVocableId());
		
		result.seteFactor(to.geteFactor());
		result.setNextTestDate(to.getNextTestDate());
		result.setTestInterval(to.getTestInterval());
		result.setTestCount(to.getTestCount());

		return result;
	}

	@Override
	protected TestedVocableDTO getToInstance() {
		return new TestedVocableDTO();
	}

	@Override
	protected TestedVocable getFromInstance() {
		return new TestedVocable();
	}
}
